﻿///<reference path="jquery-1.4.1.min.js" />
///<reference path="jquery.validate.js" />


$(function () {
    jQuery.validator.addClassRules({
        firstname: {
            require_firstname: true
        }
        , lastname: {
            require_lastname: true
        },
        phone: {
            require_phone: true,
        }
        , address1: {
            require_address1: true
        },
        city: {
            require_city: true
        },
        postcode: {
            require_postcode: true,
        },
        region: {
            require_region: true
        },
        name: {
            require_name: true
        },
        require_email: {
            require_email: true,
            email: true
        },
        question: {
            require_qustion: true,
            maxlength: 200
        },
        review: {
            require_review: true,
            maxlength: 500
        }
    });

    jQuery.validator.addMethod('require_firstname', jQuery.validator.methods.required, 'Please enter first name');
    jQuery.validator.addMethod('require_lastname', jQuery.validator.methods.required, 'Please enter last name');
    jQuery.validator.addMethod('require_phone', jQuery.validator.methods.required, 'Please enter phone nuber');
    jQuery.validator.addMethod('require_address1', jQuery.validator.methods.required, 'Please enter address');
    jQuery.validator.addMethod('require_city', jQuery.validator.methods.required, 'Please enter city');
    jQuery.validator.addMethod('require_postcode', jQuery.validator.methods.required, 'Please enter postcode');
    jQuery.validator.addMethod('require_region', jQuery.validator.methods.required, 'Please enter region');
    jQuery.validator.addMethod('require_name', jQuery.validator.methods.required, 'Please enter name');
    jQuery.validator.addMethod('require_email', jQuery.validator.methods.required, 'Please enter email');
    jQuery.validator.addMethod('require_qustion', jQuery.validator.methods.required, 'Please enter question');
    jQuery.validator.addMethod('require_review', jQuery.validator.methods.required, 'Please enter review');
    jQuery.validator.addMethod('regex', function (value, element, regexp) {
        var check = false;
        var re = new RegExp(regexp);
        return re.test(value);
    }, "Please enter valid content");
});